package com.zkingsoft.services.bus.impl;

import com.zkingsoft.dao.bus.BusCformDao;
import org.springframework.beans.factory.annotation.Autowired;
import com.zkingsoft.util.ModelUtils;
import com.zkingsoft.pojo.PaginationVO;
import java.util.List;
import com.zkingsoft.services.bus.BusCformService;
import org.springframework.stereotype.Service;
import com.zkingsoft.exception.GlobleException;
import java.util.Map;
import com.zkingsoft.model.bus.BusCform;

/**
 * This field was generated by Zking.software.Codegen.
 * @date 2016-12-28 10:12
 */
@Service("busCformService")
public class  BusCformServiceImpl implements    BusCformService  {

	
	@Autowired
	private BusCformDao busCformDao;
	
	
	@Override
	public int add(BusCform busCform){
		
		return busCformDao.insert(busCform);
		
	}
	
	@Override
	public int batchAdd(List<BusCform>  busCformList) {
		return busCformDao.batchInsert(busCformList);
	}
	
	
   	
    @Override
	public int modifyByMap(BusCform oldBusCform
	,BusCform newBusCform){
	
		if (!ModelUtils.isModified(oldBusCform, newBusCform)) {
			return 1;
		}
		Map<String, Object> modifyMap=null;
		try {
			modifyMap = ModelUtils.comparePojo2Map(oldBusCform, newBusCform);
		} catch (Exception e) {
			new GlobleException("数据对比失败");
		}
		if (modifyMap.size() > 0) {
			modifyMap.put("cfId", oldBusCform.getCfId());
			busCformDao.updateByMap(modifyMap);
		}
		return 1;
	}
	
	@Override
	public int modifyByModel(BusCform busCform){
	
		return busCformDao.updateByModel(busCform);
	
	}
	
	
	
	@Override
	public int remove(List<Long> list){
	
		return busCformDao.deleteByIds(list);
	
	}

	@Override
	public int removeById(Long cfId){
	
		return busCformDao.deleteById(cfId);
	
	}
	
	@Override
	public int removeByModel(BusCform busCform){
	
		return busCformDao.deleteByModel(busCform);
	
	}
	
	
	@Override
	public List<BusCform> findInPage(BusCform busCform,  PaginationVO pageVo){
	
		return busCformDao.selectInPage(busCform , pageVo);
	
	}
	
	@Override
	public List<BusCform> findByModel(BusCform busCform){
	
		return busCformDao.selectByModel(busCform);
	
	}
	
	@Override
	public int  findTotal(BusCform busCform){
	
		return busCformDao.selectTotalRecord(busCform);
	
	}
	
	@Override
	public BusCform  findById(Long cfId){
	
		return busCformDao.selectById(cfId);
	
	}

   	
	
	
}